package retrofit.boot.hystrix.strategy;

import com.netflix.hystrix.HystrixCommandKey;
import com.netflix.hystrix.HystrixCommandProperties;
import com.netflix.hystrix.HystrixThreadPoolKey;
import com.netflix.hystrix.HystrixThreadPoolProperties;
import com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy;

/**
 * Created by wulg on 2019/10/22
 * description:HystrixPropertiesStrategy继承类
 */
public class RetrofitHystrixPropertiesStrategy extends HystrixPropertiesStrategy {

    @Override
    public HystrixCommandProperties getCommandProperties(HystrixCommandKey commandKey, HystrixCommandProperties.Setter builder) {
        HystrixCommandKey recover = HystrixCommandKey.Factory.asKey(commandKey.name());
        return super.getCommandProperties(recover, builder);
    }

    @Override
    public String getCommandPropertiesCacheKey(HystrixCommandKey commandKey, HystrixCommandProperties.Setter builder) {
        HystrixCommandKey recover = HystrixCommandKey.Factory.asKey(commandKey.name());
        return super.getCommandPropertiesCacheKey(recover, builder);
    }


    @Override
    public HystrixThreadPoolProperties getThreadPoolProperties(HystrixThreadPoolKey threadPoolKey,
                                                               HystrixThreadPoolProperties.Setter builder) {
        HystrixThreadPoolKey recover = HystrixThreadPoolKey.Factory.asKey(threadPoolKey.name());
        return super.getThreadPoolProperties(recover, builder);

    }

    @Override
    public String getThreadPoolPropertiesCacheKey(HystrixThreadPoolKey threadPoolKey,
                                                  HystrixThreadPoolProperties.Setter builder) {

        HystrixThreadPoolKey recover = HystrixThreadPoolKey.Factory.asKey(threadPoolKey.name());
        return super.getThreadPoolPropertiesCacheKey(recover, builder);
    }
}
